home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / dev / misc / vahunz.lha / vahunz / Vahunz-Tschak < prev    next >
Encoding:
Text File  |  1998-09-17  |  31.7 KB  |  1,029 lines

  1. ; $VER: Vahunz-Tschak 1.1 (17.9.98)
  2. ;
  3. ; Copyright 1998 Thomas Aglassinger. All rights reserved.
  4. ;
  5. ; A case tool to create a script that runs Vahunz. The user can select a
  6. ; basic mode for vahunzation. The file list is generated automatically
  7. ; and the dignorary can be selected. On request, Vahunz can create the
  8. ; dictionary and the editor is launched immediately after creation.
  9. ;
  10. ; Additionally you can create or update dignoraries with it.
  11.  
  12. ; TODO: cleanup temporary files
  13. ; TODO: use "java.ignore" as default if vahunzing Java sources
  14. ; TODO: make a more clear interface flow by first offering to vahunz
  15. ;       source code or create a dignorary
  16.  
  17. ; Specify minimum installer version
  18.  
  19. (debug "set version")
  20. (set #minimum-installer-version 43)
  21. (set #minimum-installer-revision 3)
  22. (set #minimum-installer-id
  23.    (+ #minimum-installer-revision
  24.        (* #minimum-installer-version 65536)
  25.    )
  26. )
  27. (debug "  minimum-installer-id = " #minimum-installer-id)
  28. (debug "  current-installer-id = " @installer-version)
  29.  
  30.  
  31. ; Filename for the CLI script to be created. Later on the the source
  32. ; directory is inserted at the beginning of this name.
  33. (set #file-vahunz-it "Vahunz it!")
  34.  
  35. ; Texts for messages, prompts and help
  36.  
  37. (
  38. (set #message-welcome
  39. (cat "Welcome to Vahunz-Tschak, the script generator for Vahunz.\n"
  40. ))
  41.  
  42. (set #message-wrong-installer
  43. (cat "You have an old version of the program 'Installer' on your Amiga!\n\n"
  44.      "The installation procedure needs at least Installer "
  45.      #minimum-installer-version "." #minimum-installer-revision ".\n\n"
  46.      "Please obtain a newer version!\n\n"
  47.      "(Check Aminet or "
  48.      "the WWW site of the current owner of the rights for Amiga.)"
  49. ))
  50.  
  51. (set #message-wrong-list
  52. (cat "This script requires the standard 'c:list' command to be installed.\n\n"
  53.      "It seems you are using some incompatible replacement."
  54. ))
  55.  
  56. (set #message-overview
  57. (cat "Vahunz-Tschak is a frontend for Vahunz to spare you fiddling with "
  58.      "command line options.\n\n"
  59.      "It asks you some questions concerning "
  60.      "the location of your source code and options for vahunz. After that "
  61.      "it creates a CLI-script \"" #file-vahunz-it "\" you can invoke at "
  62.      "any time to perform the vahunzation.\n\n"
  63.      "If you are unsure about the meaning of a question, click the \"Help\" "
  64.      "button or take a look at the manual."
  65. ))
  66.  
  67. ; Choices for basic vahunz mode
  68. (set #choice-vahunz-standard "Standard")
  69. (set #choice-vahunz-exchange "Exchange")
  70. (set #choice-vahunz-rename   "The Great Renaming")
  71. (set #choice-vahunz-custom   "Custom")
  72. (set #choice-create-c        "Create C/C++ dignorary")
  73. (set #choice-create-java     "Create Java dignorary")
  74.               
  75.               
  76.  
  77. (set #prompt-vahunz-mode "Select the kind of vahunzation you want to perform:")
  78. (set #help-vahunz-mode
  79. (cat "This specifies what vahunz should do with your sources.\n\n"
  80.      #choice-vahunz-standard " - Perform a standard vahunzation mostly using "
  81.      "default options. This gives you a reasonably unreadable source code "
  82.      "without comments and indention you can use to distribute to normal "
  83.      "users who only want to compile it and nothing else."
  84.      "\n\n"
  85.      #choice-vahunz-exchange " - Works like \"" #choice-vahunz-standard "\", "
  86.      "but preserves line numbers in the vahunzed source. This gives accurate "
  87.      "line numbers referring to your original source if users report source "
  88.      "code related errors like problems during compilation."
  89.      "\n\n"
  90.      #choice-vahunz-rename " - Does not remove any data from your original "
  91.      "code but only creates a dictionary prepared for "
  92.      "\"The Great Renaming\"."
  93.      "\n\n"
  94.      #choice-vahunz-custom " - Asks you all options to be specified manually. "
  95.      "This is useful for maximum control over the vahunzation."
  96.      "\n\n"
  97.      #choice-create-c " - Lets you specify your include directory and creates "
  98.      "a dignorary from it."
  99.      "\n\n"
  100.      #choice-create-java " - Lets you specify your Javadoc directory and "
  101.      "creates a dignorary from it."
  102. ))
  103.  
  104. ; Choices for source type
  105. (set #choice-source-c    "C/C++")
  106. (set #choice-source-java "Java")
  107.  
  108. (set #prompt-source-type
  109.      "Select the type of source codes that should be vahunzed:"
  110. )
  111. (set #help-source-type
  112. (cat "The source type decides for which file pattern the source directory is "
  113.      "scanned."
  114. ))
  115.  
  116. (set #prompt-source-directory
  117. (cat "Select source directory to scan for source codes and where the support "
  118.      "files for vahunz will be stored:"
  119. ))
  120. (set #help-source-directory
  121. (cat "The directory you selected and all its sub-directories are scanned for "
  122.      "source codes to be vahunzed.\n\n"
  123.      "Support files like \"vahunz.files\" and the dictionaries are also "
  124.      "stored there. This includes the \"" #file-vahunz-it "\" CLI-script "
  125.      "created by Vahunz-Tschak at the end."
  126. ))
  127. (set #prompt-source-pattern
  128.      "Enter pattern for source file to be vahunzed:"
  129. )
  130. (set #help-source-pattern
  131. (cat "Here you can specify a AmigaDOS pattern the files in the source "
  132.      "directory have to match to be considered for vahunzation."
  133.      "\n\n"
  134.      "For example, #?.(c|h) specifies all C sources and headers."
  135.      "\n\n"
  136.      "All sub-directories within the source directory are also scanned."
  137. ))
  138.  
  139. (set #prompt-dignorary
  140.      "Select default dignorary to be used by vahunz:"
  141. )
  142. (set #help-dignorary
  143. (cat "The dignorary is a special dictionary containing names you know that "
  144.      "you don't want them to vahunz already beforehand. It usually "
  145.      "contains names of functions and constants of standard and system "
  146.      "libraries.\n\n"
  147.      "If you do not want to use a dignorary, choose \"empty.ignore\"."
  148. ))
  149.  
  150. (set #prompt-custom-switches "Select the switches you want to enable")
  151. (set #help-custom-switches
  152. (cat "Here you can enable switches that will influence the output Vahunz "
  153.      "creates."
  154. ))
  155.  
  156. (set #message-create-vahunz-files-1
  157.      "Creating \""
  158. )
  159. (set #message-create-vahunz-files-2
  160.      "\" using the following command:"
  161. )
  162. (set #help-create-vahunz-files
  163. (cat "This command creates the \"vahunz.files\" containing all source files "
  164.      "vahunz should take into account."
  165. ))
  166.  
  167. (set #message-create-vahunz-ignore-1
  168.      "Creating \""
  169. )
  170. (set #message-create-vahunz-ignore-2
  171.      "\" using the following command:"
  172. )
  173. (set #help-create-vahunz-ignore
  174. (cat "This command creates dignorary \"vahunz.ignore\" containig all names "
  175.      "to be ignored."
  176. ))
  177.  
  178. (set #prompt-create-vahunz-it
  179. (cat "Writing \"" #file-vahunz-it "\""
  180. ))
  181. (set #help-vahunz-it
  182. (cat "\"" #file-vahunz-it "\" is the CLI-script created by Vahunz-Tschak "
  183.      "that actually performs the vahunzation. "
  184.      "\n\n"
  185.      "You can call it whenever you updated your original source code and "
  186.      "want to create a new vahunzed version."
  187. ))
  188.  
  189. (set #prompt-target-directory
  190. (cat "Select target directory where the vahunzed source code should be "
  191.      "stored:"
  192. ))
  193. (set #help-target-directory
  194. (cat "To preserve your original source code, the vahunzed one is written "
  195.      "to a different directory, but with the same filenames."
  196.      "\n\n"
  197.      "This usually allows you to use the same scripts and Makefile for "
  198.      "compilation as for the original."
  199. ))
  200.  
  201. (set #work-create-script  "Creating script")
  202. (set #work-copy-dignorary "Copying dignorary from")
  203.  
  204. (set #prompt-launch-vahunz
  205. (cat "The script has been created. To also create the dictionary it has to be "
  206.      "executed.\n\n"
  207.      "Do you want me to start the script now?"
  208. ))
  209. (set #help-launch-vahunz
  210. (cat "You can execute the script now to make vahunz extract all names of your "
  211.      "source code and create the dictionary.\n\n"
  212.      "If you do not want to do that right now, you can skip this part and "
  213.      "execute the script later from Workbench or CLI."
  214. ))
  215.  
  216. (set #status-vahunzing
  217. (cat "Vahunzing...\n\n"
  218.      "(This can take a while)"
  219. ))
  220.  
  221. (set #prompt-editor
  222. (cat "The dictionary has been created.\n\n"
  223.      "You should load it into your editor and modify the lines you want to "
  224.      "vahunz/rename."
  225. ))
  226. (set #help-editor
  227. (cat "Your editor according to the environment variable EDITOR will be "
  228.      "started and load the dictionary.\n\n"
  229.      "Mark words you want to vahunz with plus (+) and those you want to "
  230.      "ignore with minus (-).\n\n"
  231.      "To rename a name, leave the first character blank and specify the "
  232.      "new name after an equal sign (=), for example:\n\n"
  233.      "\" rdcfg=read_settings\""
  234. ))
  235.  
  236. (set #message-exit
  237. (cat "A CLI-script has been created in \"%s\"."
  238.      "\n\n"
  239.      "You can perform the vahunzation by executing this script from CLI "
  240.      "or by double-clicking it from the Workbench."
  241.      "\n\n"
  242.      "As the script automatically goes to the source directory and also "
  243.      "restores the current directory upon exit, you can safely invoke it "
  244.      "from other scripts, Makefiles or similar."
  245.      "\n\n"
  246.      "Happy Vahunzing!"
  247. ))
  248. )
  249.  
  250. (set #prompt-include-directory "Select C/C++ include directory")
  251. (set #help-include-directory
  252. (cat "The include directory contains all your header files with names you want "
  253.      "to ignore when vahunzing source codes."
  254. ))
  255.  
  256. (set #working-list-include-files  "Creating include file list")
  257. (set #working-scan-include-files  "Scanning include files")
  258. (set #working-translate-dignorary "Replacing blanks by hyphens")
  259. (set #working-cleanup-dignorary   "Cleaning up dignorary")
  260.  
  261. (set #prompt-javadoc-directory "Select include directory")
  262. (set #help-javadoc-directory
  263. (cat "The include directory contains your system header files."
  264.      "\n\n"
  265.      "They usually contain variables, prototypes and macros you do not "
  266.      "want to vahunz."
  267. ))
  268.  
  269. (set #prompt-javadoc-directory "Select Javadoc directory")
  270. (set #help-javadoc-directory
  271. (cat "The Javadoc directory contains the API documentation in HTML format. All "
  272.      "documents matching the file pattern \"[a-z]-index.html\" in this "
  273.      "directory are scanned for references."
  274.      "\n\n"
  275.      "That means, a file named \"a-index.html\" has to exist in the directory "
  276.      "you select, otherwise it will be rejected."
  277. ))
  278. (set #message-bad-javadoc-directory
  279. (cat "The directory selected does not contain a file named \"a-index.html\". "
  280.      "Therefor this is not considered to be a directory containing API "
  281.      "documentation in JavaDoc format."
  282.      "\n\n"
  283.      "Select a proper directory next time."
  284. ))
  285.  
  286. (set #working-scan-javadoc "Scanning \"%s\"")
  287. (set #working-cleanup-javadoc "Cleaning temporary dignorary using vahunz")
  288.  
  289. (set #prompt-target-dignorary "Specify target dignorary to create")
  290. (set #help-target-dignorary
  291. (cat "Specify directory and filename of the target directory."
  292.      "\n\n"
  293.      "Preferably, it should be stored in the standard dignorary directory "
  294.      "and should have the suffix \".ignore\"."
  295. ))
  296.  
  297. (set #message-exit-dignorary
  298. (cat "The new dignorary has been stored in \"%s\"."
  299.      "\n\n"
  300.      "It is ready for your next vahunzation."
  301. ))
  302. ;----------------------------------------------------------------------------
  303. ; Run a command and check for a certain return code
  304. ;----------------------------------------------------------------------------
  305. (procedure P-run #name #expected-result #command
  306. (
  307.    (debug "  name = " #name)
  308.    (debug "  expt = " #expected-result)
  309.    (debug "  comd = " #command)
  310.  
  311.    (set #real-result (run #command))
  312.    (if (<> #expected-result #real-result)
  313.       (
  314.          (abort #name " returned " #real-result " instead of "
  315.                 #expected-result ":\n\n"
  316.                 #command)
  317.       )
  318.    )
  319. ))
  320.  
  321. ;----------------------------------------------------------------------------
  322. ; Execute a script and check for a certain return code
  323. ;----------------------------------------------------------------------------
  324. (procedure P-execute #name #expected-result #command
  325. (
  326.    (debug "  name = " #name)
  327.    (debug "  expt = " #expected-result)
  328.    (debug "  comd = " #command)
  329.  
  330.    (set #real-result (execute #command))
  331.    (if (<> #expected-result #real-result)
  332.       (
  333.          (abort #name " returned " #real-result " instead of "
  334.                 #expected-result ":\n\n"
  335.                 #command)
  336.       )
  337.    )
  338. ))
  339.  
  340. ;----------------------------------------------------------------------------
  341. ; Load certain file into editor
  342. ;----------------------------------------------------------------------------
  343. (procedure P-edit #file #prompt #help
  344. (
  345.    ; Get editor from $EDITOR or use c:Ed
  346.  
  347.    (set #editor (getenv "editor"))
  348.    (if (= "" #editor) ((set #editor "c:Ed")))
  349.  
  350.    (debug "editor = " #editor)
  351.  
  352.    ; Run editor
  353.  
  354.    (set #command-editor (cat #editor " \"" #file "\""))
  355.    (run #command-editor
  356.       (prompt #prompt)
  357.       (help #help)
  358.       (confirm "average")
  359.    )
  360. ))
  361.  
  362. ;----------------------------------------------------------------------------
  363. ; Check requirements
  364. ;----------------------------------------------------------------------------
  365.  
  366. ; Check installer version to piss people off and make them
  367. ; download a new one or dump the whole filetype (He he he).
  368. ; (The script should work with older versions, but how am I
  369. ; supposed to test this?)
  370.  
  371. (procedure P-check-requirements
  372.    (debug "check version")
  373.    (if (< @installer-version #minimum-installer-id)
  374.      (
  375.        (debug "installer too old")
  376.        (abort #message-wrong-installer)
  377.      )
  378.    )
  379.  
  380.    (debug "check list")
  381.    (if (run "list >nil: lformat=%p%n all pat=#?")
  382.      (
  383.        (debug "no/wrong list")
  384.        (abort #message-wrong-list)
  385.      )
  386. ))
  387.  
  388. ;----------------------------------------------------------------------------
  389. ; Welcome user
  390. ;----------------------------------------------------------------------------
  391.  
  392. (procedure P-welcome
  393.    (debug "welcome")
  394.    (welcome #message-welcome)
  395.  
  396.    (message #message-overview)
  397. )
  398.  
  399. ;----------------------------------------------------------------------------
  400. ; Ask for basic vahunz mode
  401. ;----------------------------------------------------------------------------
  402.  
  403. (procedure P-ask-vahunz-mode
  404.    (debug "ask vahunz mode")
  405.  
  406.    (set #vahunz-mode
  407.       (askchoice
  408.           (choices
  409.               #choice-vahunz-standard
  410.               #choice-vahunz-exchange
  411.               #choice-vahunz-rename
  412.               #choice-vahunz-custom
  413.               #choice-create-c
  414.               #choice-create-java
  415.           )
  416.           (prompt #prompt-vahunz-mode)
  417.           (help #help-vahunz-mode)
  418.       )
  419.    )
  420.    (debug "vahunz-mode = " #vahunz-mode)
  421.  
  422.    (select #vahunz-mode
  423.  
  424.       ; Standard
  425.       (set #vahunz-options "")
  426.  
  427.       ; Exchange
  428.       (set #vahunz-options "--line --random-seed=1 --store")
  429.  
  430.       ; The Great Renaming
  431.       (set #vahunz-options "--comment --indent --line --no-unused")
  432.  
  433.       ; Custom
  434.       (set #vahunz-options "*custom*")
  435.  
  436.       ; Create C dignorary
  437.       (set #vahunz-options "*create-c*")
  438.  
  439.       ; Create C dignorary
  440.       (set #vahunz-options "*create-java*")
  441.  
  442.    )
  443.    (debug "vahunz-options = " #vahunz-options)
  444. )
  445.  
  446. ;----------------------------------------------------------------------------
  447. ; Ask for source type
  448. ;----------------------------------------------------------------------------
  449.  
  450. (procedure P-ask-source-type
  451.    (debug "ask source type")
  452.  
  453.    (set #source-type
  454.       (askchoice
  455.           (choices
  456.               #choice-source-c
  457.               #choice-source-java
  458.           )
  459.           (prompt #prompt-source-type)
  460.           (help #help-source-type)
  461.       )
  462.    )
  463.    (debug "source-type = " #source-type)
  464. )
  465.  
  466. ;----------------------------------------------------------------------------
  467. ; Ask for source directory
  468. ;----------------------------------------------------------------------------
  469.  
  470. (procedure P-ask-source-directory
  471.    (debug "ask source directory")
  472.  
  473.    (if (= @app-name "debug")
  474.    (
  475.        set #source-directory "prog:SmartReadArgs"
  476.    )
  477.    (
  478.        (set #source-directory
  479.        (askdir
  480.           (prompt #prompt-source-directory)
  481.           (help #help-source-directory)
  482.           (default "Work:")
  483.        ))
  484.    )
  485.    ) ;if
  486.  
  487.    (debug "source directory = " #source-directory)
  488. )
  489.  
  490. ;----------------------------------------------------------------------------
  491. ; Ask for source pattern
  492. ;----------------------------------------------------------------------------
  493.  
  494. (procedure P-ask-source-pattern
  495.    (debug "choose source pattern")
  496.  
  497.    (select #source-type
  498.  
  499.       ; C/C++
  500.       (set #source-pattern "#?.(c|h|c++|cxx|cpp|cc)")
  501.  
  502.       ; Java
  503.       (set #source-pattern "#?.(java|jav)")
  504.  
  505.       ; Others (currently disabled)
  506.       (
  507.           (set #source-pattern
  508.           (askstring
  509.              (prompt #prompt-source-pattern)
  510.              (help #help-source-pattern)
  511.              (default "#?.(c|h|c++|cxx|cpp|cc)")
  512.           ))
  513.       )
  514.    )
  515.  
  516.    (debug "source pattern = " #source-pattern)
  517. )
  518.  
  519. ;----------------------------------------------------------------------------
  520. ; Ask for dignorary
  521. ;----------------------------------------------------------------------------
  522.  
  523. (procedure P-ask-dignorary
  524.    (debug "ask dignorary")
  525.  
  526.    (set #dignorary
  527.    (askfile
  528.       (prompt #prompt-dignorary)
  529.       (help #help-dignorary)
  530.       (default "dignorary/amiga.ignore")
  531.    ))
  532.  
  533.    (debug "dignorary = " #dignorary)
  534. )
  535.  
  536. ;----------------------------------------------------------------------------
  537. ; Ask for target directory
  538. ;----------------------------------------------------------------------------
  539.  
  540. (procedure P-ask-target-directory
  541.    (debug "ask target directory")
  542.  
  543.    (set #target-directory
  544.    (askdir
  545.       (prompt #prompt-target-directory)
  546.       (help #help-target-directory)
  547.       (default "ram:")
  548.    ))
  549.  
  550.    (debug "dignorary = " #target-directory)
  551. )
  552.  
  553. ;----------------------------------------------------------------------------
  554. ; Ask options in case of vahunz mode set to "Custom"
  555. ;----------------------------------------------------------------------------
  556. (procedure P-ask-custom-switches
  557.    (if (= #vahunz-options "*custom*")
  558.       (
  559.          ; Ask for switches
  560.  
  561.          (set #options
  562.          (askoptions
  563.             (prompt #prompt-custom-switches)
  564.             (help #help-custom-switches)
  565.             (default 0)
  566.             (choices
  567.                "Preserve comments (--comment)"
  568.                "Preserve indention (--indent)"
  569.                "Preserve line numbers (--line)"
  570.                "Remove unused names from dictionary (--no-unused)"
  571.                "Store vahunzed names in dictionary (--store)"
  572.                "Suppress warning messages (--no-warning)"
  573.             )
  574.          ))
  575.          (set #vahunz-options "")
  576.          (if (IN #options 0) (set #vahunz-options (cat #vahunz-options " --comment")))
  577.          (if (IN #options 1) (set #vahunz-options (cat #vahunz-options " --indent")))
  578.          (if (IN #options 2) (set #vahunz-options (cat #vahunz-options " --line")))
  579.          (if (IN #options 3) (set #vahunz-options (cat #vahunz-options " --no-unused")))
  580.          (if (IN #options 4) (set #vahunz-options (cat #vahunz-options " --store")))
  581.          (if (IN #options 5) (set #vahunz-options (cat #vahunz-options " --no-warning")))
  582.       )
  583.    )
  584. )
  585.  
  586. ;----------------------------------------------------------------------------
  587. ; Create "vahunz.files"
  588. ;----------------------------------------------------------------------------
  589.  
  590. (procedure P-create-vahunz.files
  591.    (set #vahunz-files (tackon #source-directory "vahunz.files"))
  592.    (set #file-command-list "t:vahunz-tschack-list.tmp")
  593.  
  594.    (working "Creating \"" #vahunz-files "\"")
  595.  
  596.    (set #command-sequence-list
  597.    (cat "cd \"" #source-directory "\"\n"
  598.         "list lformat=%p%n all "
  599.            "pat=\"" #source-pattern "\" "
  600.            ">\"" #vahunz-files "\"\n"
  601.    ))
  602.  
  603.    (debug "command: " #command-sequence-list)
  604.  
  605.    (textfile
  606.       (dest #file-command-list)
  607.       (append #command-sequence-list)
  608.    )
  609.  
  610.    (P-execute "#file-command-list" 0 #file-command-list)
  611. )
  612.  
  613. ;----------------------------------------------------------------------------
  614. ; Create "vahunz.ignore"
  615. ;----------------------------------------------------------------------------
  616.  
  617. (procedure P-create-vahunz.ignore
  618.    (set #vahunz-ignore (tackon #source-directory "vahunz.ignore"))
  619.  
  620.    (set #command-copy-dignorary
  621.    (cat "copy quiet clone "
  622.         "from=\"" #dignorary "\" "
  623.         "to=\"" #vahunz-ignore "\""
  624.    ))
  625.  
  626.    (debug "command: " #command-copy-dignorary)
  627.  
  628.    (working #work-copy-dignorary " \"" #vahunz-ignore "\"")
  629.  
  630.    (P-run "#command-copy-dignorary" 0 #command-copy-dignorary)
  631. )
  632.  
  633. ;----------------------------------------------------------------------------
  634. ; Create "Vahunz it!"
  635. ;----------------------------------------------------------------------------
  636.  
  637. (procedure P-create-vahunz-it
  638.    (set #vahunz-it (tackon #source-directory #file-vahunz-it))
  639.    (set #vahunz-it-icon (cat #vahunz-it ".info"))
  640.  
  641.    (working #work-create-script " \"" #vahunz-it "\"")
  642.  
  643.    (set #command-vahunz-it
  644.    (cat "assign vahunz-cd-<$$>: \"\"\n"
  645.         "cd \"" #source-directory "\"\n"
  646.         (expandpath "vahunz")
  647.             " " #vahunz-options
  648.             " \"--output=" #target-directory "\" "
  649.         "\n"
  650.         "cd vahunz-cd-<$$>:\n"
  651.         "assign vahunz-cd-<$$>: remove\n"
  652.    ))
  653.  
  654.    (debug "vahunz-it contents:\n---\n"
  655.           #command-vahunz-it
  656.           "---")
  657.  
  658.    (textfile
  659.       (prompt #promp-create-vahunz-it)
  660.       (help #help-vahunz-it)
  661.       (dest #vahunz-it)
  662.       (append #command-vahunz-it)
  663.    )
  664.  
  665.    (set #command-copy-icon
  666.    (cat "copy quiet clone "
  667.         "from=tschak/def_vahunz.info "
  668.         "to=\"" #vahunz-it-icon "\""
  669.    ))
  670.  
  671.    (P-run "#command-copy-icon" 0 #command-copy-icon)
  672.  
  673.    ; Set "S" protection bit of "Vahunz it!"
  674.    (set #command-protect-vahunz-it
  675.    (cat "protect \"" #vahunz-it "\" +s"
  676.    ))
  677.  
  678.    (P-run "#command-protect-vahunz-it" 0 #command-protect-vahunz-it)
  679. )
  680.  
  681. ;----------------------------------------------------------------------------
  682. ; Invoke "Vahunz it!"
  683. ;----------------------------------------------------------------------------
  684.  
  685. (procedure P-invoke-vahunt-it
  686.    (set #vahunz-launched
  687.    (askbool
  688.       (prompt #prompt-launch-vahunz)
  689.       (help #help-launch-vahunz)
  690.       (default 1)
  691.    ))
  692.  
  693.    (debug "launch vahunz = " #vahunz-launched)
  694.  
  695.    (if #vahunz-launched
  696.       (
  697.          (working #status-vahunzing)
  698.          (P-run "#vahunz-it" 0 (cat "execute \"" #vahunz-it "\""))
  699.  
  700.          ; We can't use P-execute here because it does not quote the name
  701.       )
  702.    )
  703. )
  704.  
  705. ;----------------------------------------------------------------------------
  706. ; Edit "vahunz.names"
  707. ;----------------------------------------------------------------------------
  708.  
  709. (procedure P-edit-vahunz.names
  710.    (set #vahunz-names (tackon #source-directory "vahunz.names"))
  711.    (if #vahunz-launched (P-edit #vahunz-names #prompt-editor #help-editor))
  712. )
  713.  
  714. ;----------------------------------------------------------------------------
  715. ; Exit message
  716. ;----------------------------------------------------------------------------
  717.  
  718. (procedure P-exit
  719.    (exit
  720.        (#message-exit #vahunz-it)
  721.        (quiet)
  722. ))
  723.  
  724. ;----------------------------------------------------------------------------
  725. ; Ask for include directory
  726. ;----------------------------------------------------------------------------
  727.  
  728. (procedure P-ask-include-directory
  729. (
  730.    (debug "ask include directory")
  731.  
  732.    (set #include-directory
  733.    (askdir
  734.       (prompt #prompt-include-directory)
  735.       (help #help-include-directory)
  736.       (default "include:")
  737.    ))
  738. ))
  739.  
  740. ;----------------------------------------------------------------------------
  741. ; Create include file list
  742. ;----------------------------------------------------------------------------
  743.  
  744. (procedure P-create-include-files
  745. (
  746.    (debug "list include files")
  747.  
  748.    (working #working-list-include-files)
  749.  
  750.    (set #command-list-include
  751.    (cat "list >ram:temporary.files lformat=%p%n all pat=#?.h "
  752.         #include-directory
  753.    ))
  754.  
  755.    (P-run "#command-list-include" 0 #command-list-include)
  756. ))
  757.  
  758. ;----------------------------------------------------------------------------
  759. ; Scan include file
  760. ;----------------------------------------------------------------------------
  761.  
  762. (procedure P-scan-include-files
  763. (
  764.    (debug "scan include files")
  765.  
  766.    (working #working-scan-include-files)
  767.  
  768.    (delete "ram:temporary.names"  (optional "force"))
  769.    (delete "ram:temporary.ignore" (optional "force"))
  770.  
  771.    (set #command-scan-include "vahunz --base-name ram:temporary")
  772.  
  773.    (P-run "#command-scan-include" 0 #command-scan-include)
  774. ))
  775.  
  776. ;----------------------------------------------------------------------------
  777. ; Translate and append include dignorary
  778. ;----------------------------------------------------------------------------
  779.  
  780. (procedure P-translate-dignorary
  781. (
  782.    (debug "translate dignorary")
  783.  
  784.    (working #working-translate-dignorary)
  785.  
  786.    (set #command-translate-dignorary
  787.    (cat "tschak/blank-to-hyphen"
  788.         " <ram:temporary.names"
  789.         " >>ram:temporary.ignore"
  790.    ))
  791.  
  792.    (P-run "#command-translate-dignorary" 0 #command-translate-dignorary)
  793.  
  794.    ; Delete the name list and launch vahunz again to sort the whole mess
  795.    ; and kick out possible duplicates
  796.    (debug "cleanup dignorary")
  797.  
  798.    (working #working-cleanup-dignorary)
  799.    (delete "ram:temporary.names" (optional "force"))
  800.  
  801.    (set #command-cleanup-dignorary "vahunz --base-name ram:temporary")
  802.    (P-run "#command-cleanup-dignorary" 0 #command-cleanup-dignorary)
  803. ))
  804.  
  805.  
  806.  
  807. ;----------------------------------------------------------------------------
  808. ; Ask for target dignorary name
  809. ;----------------------------------------------------------------------------
  810.  
  811. (procedure P-ask-target-dignorary #name
  812. (
  813.    (debug "ask target dignorary")
  814.  
  815.    (set #target-dignorary
  816.    (askfile
  817.       (prompt #prompt-target-dignorary)
  818.       (help #help-target-dignorary)
  819.       (default (tackon "dignorary" #name))
  820.    ))
  821.  
  822.    (debug "target dignorary = " #target-dignorary)
  823. ))
  824.  
  825. ;----------------------------------------------------------------------------
  826. ; Move temporary dignorary to standard dignorary directory
  827. ;----------------------------------------------------------------------------
  828. (procedure P-move-dignorary #source-dignorary
  829. (
  830.    (debug "move dignorary")
  831.    (debug "  source = \"" #source-dignorary "\"")
  832.    (debug "  target = \"" #target-dignorary "\"")
  833.  
  834.    (copyfiles
  835.       (source #source-dignorary)
  836.       (dest (pathonly #target-dignorary))
  837.       (newname (fileonly #target-dignorary))
  838.       (optional "askuser")
  839.    )
  840.  
  841.    (delete
  842.       #source-dignorary
  843.       (optional "force")
  844.    )
  845. ))
  846.  
  847.  
  848. ;----------------------------------------------------------------------------
  849. ; Ask for JavaDoc directory
  850. ;----------------------------------------------------------------------------
  851.  
  852. (procedure P-ask-javadoc-directory
  853. (
  854.    (debug "ask javadoc directory")
  855.  
  856.    (set #javadoc-exists 0)
  857.  
  858.    (set #javadoc-directory
  859.    (askdir
  860.       (prompt #prompt-javadoc-directory)
  861.       (help #help-javadoc-directory)
  862.       (default "jdk:1.1/docs/api")
  863.    ))
  864.  
  865.    ; Check, if "a-index.html" exists in this directory
  866.    (set #javadoc-exist (exists (tackon #javadoc-directory "a-index.html")))
  867.  
  868.    (debug "#javadoc-exist = " #javadoc-exist)
  869.  
  870.    ; If not, annoy user
  871.    (if (= 0 #javadoc-exist) (abort #message-bad-javadoc-directory))
  872. ))
  873.  
  874. ;----------------------------------------------------------------------------
  875. ; Scan JavaDoc index file and append references to dignorary
  876. ;----------------------------------------------------------------------------
  877. (procedure P-scan-javadoc #filename #complete2
  878. (
  879.    ; Compute name of index file to scan
  880.    (set #javadoc-filename (tackon #javadoc-directory #filename))
  881.  
  882.    (debug "scan " #javadoc-filename)
  883.  
  884.    (complete #complete2)
  885.    (working (#working-scan-javadoc #javadoc-filename))
  886.  
  887.    ; Compute command to scan
  888.    (set #command-scan-javadoc
  889.    (cat "sys:rexxc/rx tschak/scan-javadoc.rexx \"" #javadoc-filename "\" \"ram:java.ignore\""
  890.    ))
  891.  
  892.    (P-run "#command-scan-javadoc" 0 #command-scan-javadoc)
  893. ))
  894.  
  895.  
  896. ;----------------------------------------------------------------------------
  897. ; Scan JavaDoc directory and create dignorary from it
  898. ;----------------------------------------------------------------------------
  899. (procedure P-scan-javadoc-directory #complete
  900. (
  901.    (debug "scan javadoc directory")
  902.  
  903.    (set #script-cleanup-dignorary "t:cleanup-dignorary")
  904.  
  905.    ; Setup temporary files
  906.    (P-run "#command-reset-scan" 0 "echo \"\" >ram:java.ignore noline")
  907.    (P-run "#command-reset-scan" 0 "echo \"\" >ram:dummy.java")
  908.    (P-run "#command-reset-scan" 0 "echo \"dummy.java\" >ram:java.files")
  909.    (delete "ram:java.names")
  910.  
  911.    (P-scan-javadoc "a-index.html" (+ #complete  1))
  912.    (P-scan-javadoc "b-index.html" (+ #complete  2))
  913.    (P-scan-javadoc "c-index.html" (+ #complete  3))
  914.    (P-scan-javadoc "d-index.html" (+ #complete  4))
  915.    (P-scan-javadoc "e-index.html" (+ #complete  5))
  916.    (P-scan-javadoc "f-index.html" (+ #complete  6))
  917.    (P-scan-javadoc "g-index.html" (+ #complete  7))
  918.    (P-scan-javadoc "h-index.html" (+ #complete  8))
  919.    (P-scan-javadoc "i-index.html" (+ #complete  9))
  920.    (P-scan-javadoc "j-index.html" (+ #complete 10))
  921.    (P-scan-javadoc "k-index.html" (+ #complete 11))
  922.    (P-scan-javadoc "l-index.html" (+ #complete 12))
  923.    (P-scan-javadoc "m-index.html" (+ #complete 13))
  924.    (P-scan-javadoc "n-index.html" (+ #complete 14))
  925.    (P-scan-javadoc "o-index.html" (+ #complete 15))
  926.    (P-scan-javadoc "p-index.html" (+ #complete 16))
  927.    (P-scan-javadoc "q-index.html" (+ #complete 17))
  928.    (P-scan-javadoc "r-index.html" (+ #complete 18))
  929.    (P-scan-javadoc "s-index.html" (+ #complete 19))
  930.    (P-scan-javadoc "t-index.html" (+ #complete 20))
  931.    (P-scan-javadoc "u-index.html" (+ #complete 21))
  932.    (P-scan-javadoc "v-index.html" (+ #complete 22))
  933.    (P-scan-javadoc "w-index.html" (+ #complete 23))
  934.    (P-scan-javadoc "x-index.html" (+ #complete 24))
  935.    (P-scan-javadoc "y-index.html" (+ #complete 25))
  936.    (P-scan-javadoc "z-index.html" (+ #complete 26))
  937.  
  938.    (complete (+ #complete 30))
  939.    (working #working-cleanup-javadoc)
  940.  
  941.    (set #command-cleanup-dignorary
  942.    (cat "cd ram:\n"
  943.         (expandpath "vahunz") " --base-name java --no-warning --quiet\n"
  944.    ))
  945.  
  946.    (textfile
  947.       (dest #script-cleanup-dignorary)
  948.       (append #command-cleanup-dignorary)
  949.    )
  950.  
  951.    (P-execute "#script-cleanup-dignorary" 0 #script-cleanup-dignorary)
  952.  
  953.    (debug "cleanup temporary files")
  954.  
  955.    (set #command-cleanup
  956.    (cat "delete >nil: quiet force"
  957.         " ram:java.names"
  958.         " ram:java.files"
  959.         " ram:dummy.java"
  960.    ))
  961.  
  962.    (run #command-cleanup)
  963. ))
  964.  
  965. ;----------------------------------------------------------------------------
  966. ; Exit message for created dignoraries
  967. ;----------------------------------------------------------------------------
  968.  
  969. (procedure P-exit-dignorary
  970.    (exit
  971.        (#message-exit-dignorary #target-dignorary)
  972.        (quiet)
  973. ))
  974.  
  975. ;----------------------------------------------------------------------------
  976. ; "Wollt ihr das totale Programm?"
  977. ;----------------------------------------------------------------------------
  978.  
  979. (complete   0) (P-check-requirements)
  980. (complete   5) (P-welcome)
  981.  
  982. (complete  10) (P-ask-vahunz-mode)
  983.  
  984. (set #flow-selector 0)
  985. (if (= #vahunz-options "*create-c*")    (set #flow-selector 1))
  986. (if (= #vahunz-options "*create-java*") (set #flow-selector 2))
  987.  
  988. (select #flow-selector
  989.    (
  990.       ; Vahunz source code
  991.       (complete  20) (P-ask-custom-switches)
  992.       (complete  25) ; (P-ask-custom-name-length)
  993.       (complete  30) ; (P-ask-custom-prefix)
  994.       (complete  35) ; (P-ask-custom-random-seed)
  995.       (complete  40) ; (P-ask-custom-vahunz-length)
  996.       (complete  45) (P-ask-source-type)
  997.       (complete  50) (P-ask-source-directory)
  998.       (complete  55) (P-ask-source-pattern)
  999.       (complete  60) (P-ask-dignorary)
  1000.       (complete  65) (P-ask-target-directory)
  1001.  
  1002.       (complete  75) (P-create-vahunz.files)
  1003.       (complete  80) (P-create-vahunz.ignore)
  1004.       (complete  85) (P-create-vahunz-it)
  1005.       (complete  90) (P-invoke-vahunt-it)
  1006.       (complete  95) (P-edit-vahunz.names)
  1007.       (complete 100) (P-exit)
  1008.    )
  1009.    (
  1010.       ; Create C/C++ dignorary
  1011.       (complete  30) (P-ask-include-directory)
  1012.       (complete  50) (P-ask-target-dignorary "amiga.ignore")
  1013.       (complete  70) (P-create-include-files)
  1014.       (complete  80) (P-scan-include-files)
  1015.       (complete  90) (P-translate-dignorary)
  1016.       (complete  95) (P-move-dignorary "ram:temporary.ignore")
  1017.       (complete 100) (P-exit-dignorary)
  1018.    )
  1019.    (
  1020.       ; Create Java dignorary
  1021.       (complete  30) (P-ask-javadoc-directory)
  1022.       (complete  50) (P-ask-target-dignorary "java.ignore")
  1023.       (complete  60) (P-scan-javadoc-directory 60)
  1024.       (complete  95) (P-move-dignorary "ram:java.ignore")
  1025.       (complete 100) (P-exit-dignorary)
  1026.    )
  1027. )
  1028.  
  1029.